//
//  FoodListViewController.m
//  OrderMeal
//
//  Created by 江苏宏创 on 14-7-25.
//  Copyright (c) 2014年 qkong. All rights reserved.
//

#import "FoodListViewController.h"
#import "SendHttpOperation.h"
#import "Protocols.h"
#import "FoodTableViewCell.h"
@interface FoodListViewController ()<UITableViewDataSource,UITableViewDelegate,PassFoodProtocol>{
    NSMutableArray *tableData;
}
@end

@implementation FoodListViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [[SendHttpOperation sharedHttpOperation]getFoodListWithRegionId:@"1"
                                                               Date:@"2014-07-25"
                                                        GoodsTypeId:@"1"];
    [SendHttpOperation sharedHttpOperation].passFoodDelegate = self;
    // Do any additional setup after loading the view.
}

-(void)passFoodData:(NSMutableArray *)foodData{
    dispatch_async(dispatch_get_main_queue(), ^{
        tableData = foodData;
        NSLog(@"tableData--->%@",tableData);
        [self.foodTable reloadData];
    });
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark -表视图数据
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return tableData.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    FoodTableViewCell *foodCell = [tableView dequeueReusableCellWithIdentifier:@"FoodCell"];
    NSDictionary *foodInfo = tableData[indexPath.row];
    foodCell.imageView.image = [UIImage imageNamed:@"defaultNoImage.png"];
    foodCell.foodName.text = foodInfo[@"goods"][@"name"];
    foodCell.foodPrice.text = foodInfo[@"goods"][@"finalPrice"];
    foodCell.foodHotTypeName.text = foodInfo[@"hotTypeName"];
    return foodCell;
}


#pragma mark -选择类型
- (IBAction)didSelectType:(id)sender {
    switch ([sender selectedSegmentIndex]) {
        case 0:
            //商务套餐
            break;
        case 1:
            //缤纷饮料
            break;
        case 2:
            //休闲甜点
            break;
            
        default:
            break;
    }
}



@end
